<?php
require_once("vcl/vcl.inc.php");
require_once("lib/db_connection.php");
//Includes
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");

//Class definition
class Replace_Body extends Page
{
       public $hiddenId = null;
       public $Image1 = null;
       public $edRepIgnitionCode = null;
       public $edRepDoor = null;
       public $Label99 = null;
       public $Label98 = null;
       public $edRepIntCode = null;
       public $edRepIntColor = null;
       public $Label97 = null;
       public $Label96 = null;
       public $edRepBodyNum = null;
       public $edRepPcode = null;
       public $edRepPcolor = null;
       public $btnCancelBody = null;
       public $btnReplaceBody = null;
       public $Label95 = null;
       public $Label94 = null;
       public $Label102 = null;
       function edRepPcodeJSKeyUp($sender, $params)
       {

       ?>
       //Add your javascript code here
       window.opener.document.getElementById('edpaintcode').value = document.getElementById('edRepPcode').value;
       <?php

       }

       function Replace_BodyCreate($sender, $params)
       {
       $veh_id = $_GET['veh_id'];

       if($veh_id!='' || $veh_id!=null)
       $this->hiddenId->setValue($veh_id);

       $this->edRepBodyNum->Text = '';
       $this->edRepPcode->Text = '';
       $this->edRepPcolor->Text = '';
       $this->edRepIntCode->Text = '';
       $this->edRepIntColor->Text = '';
       $this->edRepIgnitionCode->Text = '';
       $this->edRepDoor->Text = '';


       }

       function edRepDoorJSKeyUp($sender, $params)
       {

       ?>
       //Add your javascript code here
       window.opener.document.getElementById('eddoorkey').value = document.getElementById('edRepDoor').value;
       <?php

       }

       function edRepIgnitionCodeJSKeyUp($sender, $params)
       {

       ?>
       //Add your javascript code here
       window.opener.document.getElementById('edignition').value = document.getElementById('edRepIgnitionCode').value;
       <?php

       }

       function edRepIntColorJSKeyUp($sender, $params)
       {

       ?>
       //Add your javascript code here
       window.opener.document.getElementById('edintcolor').value = document.getElementById('edRepIntColor').value;
       <?php

       }

       function edRepIntCodeJSKeyUp($sender, $params)
       {

       ?>
       //Add your javascript code here
       window.opener.document.getElementById('edintcode').value = document.getElementById('edRepIntCode').value;
       <?php

       }

       function edRepPcolorJSKeyUp($sender, $params)
       {

       ?>
       //Add your javascript code here
       window.opener.document.getElementById('edpaintcolor').value = document.getElementById('edRepPcolor').value;
       <?php

       }

       function btnECancelJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       window.close();
       <?php

       }

       function btnReplaceBodyClick($sender, $params)
       {
       $result = mysql_query("insert into body_history_tbl (comp_id,
       veh_id,
       body_num,
       paint_code,
       paint_color,
       interior_code,
       interior_color,
       ignition_code,
       door_key)

       values ('".$_SESSION['company_id']."',
       '".$this->hiddenId->getValue()."',
       '".$this->edRepBodyNum->Text."',
       '".$this->edRepPcode->Text."',
       '".$this->edRepPcolor->Text."',
       '".$this->edRepIntCode->Text."',
       '".$this->edRepIntColor->Text."',
       '".$this->edRepIgnitionCode->Text."',
       '".$this->edRepDoor->Text."')")or die("INSERT BODY HISTORY - " . mysql_error());

       mysql_query("update veh_engine_tbl set
       body_num = '" . $this->edRepBodyNum->Text . "',
       paint_code = '" . $this->edRepPcode->Text . "',
       paint_color = '" . $this->edRepPcolor->Text . "',
       interior_code = '" . $this->edRepIntCode->Text . "',
       interior_color = '" . $this->edRepIntColor->Text . "',
       ignition_code = '" . $this->edRepIgnitionCode->Text . "',
       door_key = '" . $this->edRepDoor->Text . "'
       where vehicle_id='" . $this->hiddenId->getValue() . "'")or die("UPDATE BODY - " . mysql_error());

       echo "<script type=text/javascript>
        alert('Body Replaced!');
        window.close();
        </script>";


       }

       function edRepBodyNumJSKeyUp($sender, $params)
       {

       ?>
       //Add your javascript code here
       window.opener.document.getElementById('edBodyNum').value = document.getElementById('edRepBodyNum').value;
       <?php

       }

}

global $application;

global $Replace_Body;

//Creates the form
$Replace_Body=new Replace_Body($application);

//Read from resource file
$Replace_Body->loadResource(__FILE__);

//Shows the form
$Replace_Body->show();

?>